Skip to content

refactor(tabs): rename TabsHost navState prop to navStateRequest#3943

Merged
kkafar merged 3 commits intomainfrom
@kkafar/refactor-tabs-nav-state-request
Apr 28, 2026
Merged

refactor(tabs): rename TabsHost navState prop to navStateRequest#3943
kkafar merged 3 commits intomainfrom
@kkafar/refactor-tabs-nav-state-request

Conversation

@kkafar
Copy link
Copy Markdown
Member

@kkafar kkafar commented Apr 27, 2026

Description

Aligns the TabsHost public API with RFC-1028's request/state distinction.

The prop currently named navState carries a request for a state change — not the state itself. The resulting state is delivered back to JS through the OnTabSelected event. Today both sides expose a field called provenance, but they refer to different things:

  • on the request: provenance of the state the request was derived from (i.e. the JS-side base),
  • on the event payload: provenance of the resulting state after the transition.

Renaming the prop and field makes this distinction explicit at the API surface and prevents downstream consumers from conflating the two.

Most other RFC-1028 deliverables are already implemented (OnTabSelected/OnTabSelectionRejected/OnTabSelectionPrevented, isNativeAction, rejectStaleNavStateUpdates, the prevention event). This PR is the remaining rename pass.

No behavior change.

Changes

  • Public TS:
    • type TabsHostNavStateTabsHostNavStateRequest
    • field provenancebaseProvenance on the request type
    • prop navStatenavStateRequest on TabsHostPropsBase
    • re-export updated in src/components/tabs/index.ts
  • Codegen specs (Android + iOS): same prop/field rename. The C++ Props struct regenerates automatically on next codegen run.
  • Native binding boundary:
    • Android: setNavStateRequest override on the ViewManager, parses selectedScreenKey + baseProvenance from the ReadableMap.
    • iOS: prop access in RNSTabsHostComponentView::updateProps.
  • Internal native state types are kept untouched — they model state, not requests:
    • Kotlin TabsNavState (data class)
    • ObjC RNSTabsNavigationState
    • TabSelectOp.navState payload (the op models a container-level state update, not a JS request)
  • Internal members holding the most recent JS request renamed for clarity:
    • Android: jsNavStatejsNavStateRequest, updateJSNavStateupdateJSNavStateRequest
    • iOS: _jsNavState_jsNavStateRequest, @property navState@property navStateRequest
  • Apps consumer (apps/.../TabsContainer.{tsx,types.tsx}) updated in lockstep so the workspace stays green; helper hook renamed useTabsHostNavStateuseTabsHostNavStateRequest.

Test plan

This is a pure rename — no behavior change is introduced. Verification focused on build/type integrity and a manual smoke test in FabricExample:

  • yarn check-types (library) — passes.
  • yarn check-types in apps/ — only pre-existing, unrelated errors remain (no errors mention navState/TabsHostNavState after the rename).
  • Android: full rebuild of FabricExample — codegen regenerates RNSTabsHostAndroidManagerInterface.setNavStateRequest(...) and the RNSTabsHostAndroidNavStateRequestStruct C++ struct; the Kotlin override compiles against the new signature.
  • iOS: pod install + build of FabricExample — codegen produces the renamed C++ Props member; the ObjC++ side reads newComponentProps.navStateRequest.{selectedScreenKey,baseProvenance}.
  • Manual smoke test in FabricExample Tabs example: drive tab changes from JS (programmatic, via the apps' TabsContainer) and from native (tab bar tap). Confirm tab selection works on both platforms and OnTabSelected events still fire as expected.

Reviewers may want to focus on:

  • src/components/tabs/host/TabsHost.types.ts — public type shape
  • both codegen specs in src/fabric/tabs/
  • the boundary conversion in TabsHostViewManager.kt::setNavStateRequest and RNSTabsHostComponentView.mm::updateProps (request's baseProvenance is fed in as the constructor's provenance: arg on the internal state types — by design)

Checklist

  • Included code example that can be used to test this change.
  • For visual changes, included screenshots / GIFs / recordings documenting the change.
  • For API changes, updated relevant public types.
  • Ensured that CI passes

Aligns the public API with RFC-1028's request/state distinction. The
prop carries a *request* for a state change (with `baseProvenance`
identifying the JS-side base it was derived from); the resulting state
arrives back via `OnTabSelected` (with `provenance`). Naming both fields
`provenance` was confusing — they refer to different generations.

- Public TS: `TabsHostNavState` → `TabsHostNavStateRequest`,
  field `provenance` → `baseProvenance`, prop `navState` → `navStateRequest`.
- Codegen specs (Android + iOS) updated to match; the C++ Props struct
  regenerates automatically.
- Native binding boundary: `setNavStateRequest` override on Android
  ViewManager, prop access on iOS `updateProps`.
- Internal native state types (`TabsNavState` Kotlin, `RNSTabsNavigationState`
  ObjC) kept — they model state, not requests. Only members that hold the
  most recent JS request are renamed (`jsNavState{,Request}`,
  `updateJSNavState{,Request}`, `_jsNavState{,Request}`). `TabSelectOp`
  payload stays `navState` since the op models a state update at the
  container level.
- Apps consumer (`apps/...`) updated in lockstep so the workspace stays
  green.

No behavior change.
@kkafar kkafar requested a review from Copilot April 28, 2026 09:37
@kkafar kkafar marked this pull request as ready for review April 28, 2026 09:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aligns the TabsHost API with RFC-1028’s request/state distinction by renaming the navState prop (and its related types/fields) to explicitly represent a request rather than the resulting navigation state.

Changes:

  • Renames public TS API: TabsHostNavStateTabsHostNavStateRequest, provenancebaseProvenance, navStatenavStateRequest.
  • Updates Fabric codegen specs (Android/iOS) to match the new prop/field names.
  • Updates native bindings and the example app consumer to use the renamed API end-to-end.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/fabric/tabs/TabsHostIOSNativeComponent.ts Renames codegen prop/type and request field to navStateRequest / baseProvenance.
src/fabric/tabs/TabsHostAndroidNativeComponent.ts Same rename for Android codegen spec.
src/components/tabs/index.ts Re-exports the renamed public TS type.
src/components/tabs/host/TabsHost.types.ts Updates public TS types, docs, and TabsHostPropsBase prop name.
src/components/tabs/host/TabsHost.ios.tsx Wires navStateRequest through to the iOS native component.
src/components/tabs/host/TabsHost.android.tsx Wires navStateRequest through to the Android native component.
ios/tabs/host/RNSTabsHostComponentView.mm Reads navStateRequest.baseProvenance from generated props and updates pending nav op.
ios/tabs/host/RNSTabsHostComponentView.h Renames the internal prop exposure to navStateRequest.
apps/src/shared/gamma/containers/tabs/TabsContainer.types.tsx Updates consumer prop omissions to the new prop name.
apps/src/shared/gamma/containers/tabs/TabsContainer.tsx Renames the hook and passes navStateRequest to Tabs.Host.
android/src/main/java/com/swmansion/rnscreens/gamma/tabs/host/TabsHostViewManager.kt Renames the view manager setter and map key parsing (baseProvenance).
android/src/main/java/com/swmansion/rnscreens/gamma/tabs/host/TabsHost.kt Renames internal members/methods holding the latest JS request.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ios/tabs/host/RNSTabsHostComponentView.mm Outdated
Comment thread ios/tabs/host/RNSTabsHostComponentView.mm Outdated
kkafar added 2 commits April 28, 2026 18:26
Aligns the iOS ivar name with the renamed `navStateRequest` prop on
RNSTabsHost. The `_js` prefix referenced the prop's prior name and is
no longer meaningful.
@kkafar kkafar merged commit 8c915dc into main Apr 28, 2026
8 checks passed
@kkafar kkafar deleted the @kkafar/refactor-tabs-nav-state-request branch April 28, 2026 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants